package test;

/**
 * @author oldliu
 * @since 1.0
 */
public class Zuichangchongfu {

    public static String find(String str) {
        String rig = null, left = null;
        for (int len = str.length() / 2; len > 0; len--) {//将字符串分隔为若干“最长字串”

            for (int i = 0; i < str.length(); i++) {//获取“最长字串”
                rig = str.substring(i, len);//刨去“最 长字串”剩下的串
                left = str.substring(rig.length());//如果剩下的串里面包含“最长字串”
                if (left.contains(rig))//判断 left.indexOf(rig)!=-1
                    return rig;
            }

        }
        return null;//啥也找不到
    }

    public static void main(String[] args) {
        String str = find("abc");
        System.out.println("?>>"+str);
    }
}
